package controller

import (
	"errors"
	"fmt"
	"net"
	"strings"
)

/*获取控制器mac地址*/
func GetNetworkMac() (mac string,err error) {
	interfaces, err := net.Interfaces()
	if err != nil {
		return "", err
	}
	for _, inter := range interfaces {
		if !strings.HasPrefix(string(inter.Name), "enp") &&
			!strings.HasPrefix(string(inter.Name), "eth") {
			continue
		}
		str :=fmt.Sprintf("%s", inter.HardwareAddr)
		return strings.Replace(str,":","",-1),nil
	}
	return "", errors.New("fail to read network mac")
}
